//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "adminActions\main.sqf"
#include <functions\core_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

if (isServer) then {
	MSO_AdminActions_EventHandler = [];
	publicVariable "MSO_AdminActions_EventHandler";
	
	GVAR(OnPlayerConnectedEventId) = ["MSO_AA_ID", "onPlayerConnected", "MSO_AA_fnc_opc"] call BIS_fnc_addStackedEventHandler;
	GVAR(OnPlayerDisconnectedEventId) = ["MSO_AA_ID", "onPlayerDisconnected", "MSO_AA_fnc_opd"] call BIS_fnc_addStackedEventHandler;
	TRACE_2("Added onPlayer Events",GVAR(OnPlayerConnectedEventId),GVAR(OnPlayerDisconnectedEventId));
};
"MSO_AdminActions_EventHandler" addPublicVariableEventHandler {(_this select 1) call FUNC(pveh);};

if (GVAR(AdminCmds) == 0) exitwith {diag_log format ["MSO-%1 Adminactions turned off - Exiting.",time];};
diag_log format ["MSO-%1 Adminactions turned on",time];
"Admin Actions" call mso_core_fnc_initStat;

if (markerType "MSO_PUNISHMENT" == "") then {diag_log format ["MSO-%1 Adminactions missing MSO_Punishment marker - Exiting.",time];};

if (isDedicated) exitWith { };

["DOM_ACTION_MENU",FUNC(createdomactionmenu)] call tyr_fnc_addhandler;

_trigger = createTrigger ["EmptyDetector" ,markerPos "MSO_PUNISHMENT"];
_trigger setTriggerArea [12, 12, (markerDir "MSO_PUNISHMENT"), true];
_trigger setTriggerActivation [side player, "PRESENT", true];
_trigger setTriggerStatements ["(player distance (markerPos 'MSO_PUNISHMENT')) < 12", "[player] spawn FNC_PUNISHMENT_PLAYER_EXEC;", ""];

if (GVAR(AdminCmds) == 1) then {
	0 spawn {
		waituntil {!isnull player};
		TRACE_1("Starting Player Functions");
		player spawn FUNC(playerMonitor);
		[] spawn FUNC(markerDisplay);
	};
};

TRACE("End");
TMFPROFILERSTOP;